//
//  TSWithDrawCashSectionHeaderView.swift
//  TSProfitProject
//
//  Created by TMS on 2019/11/5.
//  Copyright © 2019 TMS. All rights reserved.
//

import UIKit

class TSWithDrawCashSectionHeaderView: UIView {

    var nameLabel : UILabel!
    var accountLabel : UILabel!
    var bankLabel : UILabel!
    var addressLabel : UILabel!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        configViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupView(model:TSCardListModel?) {
        
        if model == nil {
            return
        }
        
        nameLabel.text = model!.bankusername
        accountLabel.text = "\(model!.banknum)"
        bankLabel.text = model!.bankname
        addressLabel.text = model!.bankadress
    }
    
    func configViews() {
        
        let container = UIView.init()
        container.backgroundColor = BASE_RED_COLOR
        container.layer.cornerRadius = 10
        container.layer.masksToBounds = true
        self.addSubview(container)
        container.snp.makeConstraints { (make) in
            make.top.equalTo(17)
            make.centerX.equalToSuperview()
            make.size.equalTo(CGSize(width: SCREEN_WIDTH - 2*12, height: 158))
        }
        
        nameLabel = createLabel(text: "开户姓名：暂无")
        container.addSubview(nameLabel)
        
        accountLabel = createLabel(text: "开户账号：暂无")
        container.addSubview(accountLabel)
        
        bankLabel = createLabel(text: "开户银行：暂无")
        container.addSubview(bankLabel)
        
        addressLabel = createLabel(text: "开户网点：暂无")
        container.addSubview(addressLabel)
        
        let labelArray = [nameLabel, accountLabel, bankLabel, addressLabel]
        labelArray.snp.distributeViewsAlong(axisType: .vertical, fixedSpacing: 15, leadSpacing: 23, tailSpacing: 23)
        labelArray.snp.makeConstraints { (make) in
            make.left.equalTo(21)
            make.right.equalTo(-21)
        }
    }
    
    func createLabel(text:String) -> UILabel {
        
        let label = UILabel.init()
        label.text = text
        label.textColor = WHITE_COLOR
        label.font = UIFont.systemFont(ofSize: 14, weight: .medium)
        label.adjustsFontSizeToFitWidth = true
        label.minimumScaleFactor = 0.8
        return label
    }
}
